﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using Jenzabar.Portal.Framework.Web.UI;
using Jenzabar.Portal.Framework.Security.Authorization; // Add reference Jenzabar.Portal.Framework.dll for operations
using Jenzabar.Portal.Framework.Web.UI;// SecuredPortletBase
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;//Add reference System.Configuration.dll
using Jenzabar.Common.Web.UI.Controls;
using System.Drawing; 



namespace Portlet.AURoster
{
    #region Operations
    [PortletOperation("CanAdminPortlet", "Can Administer Portlet", "Whether user can administer the portlet", PortletOperationScope.Portlet)]
    #region Operations
    [PortletOperation("CANVIEWROSTER", "AU_ROSTER_CAN_VIEW", "AU_ROSTER_CAN_VIEW", PortletOperationScope.Global)]
    [PortletOperation("CANADMINROSTER", "AU_ROSTER_CAN_ADMIN", "AU_ROSTER_CAN_ADMIN", PortletOperationScope.Global)]
    #endregion
    
    
    #endregion Operations
    public class Roster : SecuredPortletBase //for Secured PortletBase Add "CANACCESS" Operation in ADAM
    {
        protected override PortletViewBase GetCurrentScreen()
        {
            PortletViewBase screen = null;
            switch (this.CurrentPortletScreenName)
            {
                case "RE":
                    screen = this.LoadPortletView("ICS/Portlet.AURoster/Reg_View.ascx");
                    break;
                case "Edit":
                    screen = this.LoadPortletView("ICS/Portlet.AURoster/Edit_View.ascx");
                    break;
                case "Search":
                    //screen = this.LoadPortletView("ICS/Portlet.AURoster/Search_View.ascx");
                    screen = this.LoadPortletView("ICS/Portlet.AURoster/Default_View.ascx");
                    break;
                case "New":
                    screen = this.LoadPortletView("ICS/Portlet.AURoster/Add_View.ascx");
                    break;
                case "Default":
                    screen = this.LoadPortletView("ICS/Portlet.AURoster/Default_View.ascx");
                    break;
                default:
                    screen = this.LoadPortletView("ICS/Portlet.AURoster/Default_View.ascx");
                    break;

            }
            return screen;
        }


        protected override void OnInit(EventArgs e)
        {
            Toolbar.ItemCommand += new CommandEventHandler(Toolbar_ItemCommand);
            base.OnInit(e);
        }

        void Toolbar_ItemCommand(object sender, CommandEventArgs e)
        {
            this.NextScreen(e.CommandName);
        }

        protected override bool PopulateTabs(SuperTabs tabs)
        {
            bool showTabs = false;
            bool isAdmin = this.AccessCheck("CANADMINROSTER");
            if (this.AccessCheck("CANVIEWROSTER") || isAdmin)
            {
                tabs.Tabs.Add("Default", "Main", "Default");
                tabs.Tabs.Add("New", "AddNew", "New");
                tabs.Tabs.Add("Edit", "Modify", "Edit");
                // tabs.Tabs.Add("Search", "Search", "Search");
               
                showTabs = true;
            }
            if (isAdmin)
            {
               // tabs.Tabs.Add("Search", "Search", "Search");
                tabs.Tabs.Add("RE", "OFFICE USE", "Reg Office");
            }
            return showTabs;
        }
        //protected override bool PopulateToolbar(Toolbar toolbar)
        //{
        //    toolbar.ForeColor = Color.Green;
        //    Jenzabar.Common.Web.UI.Controls.MenuItem manage = toolbar.MenuItems.Add("", "Default");
        //    manage = toolbar.MenuItems.Add("REG OFFICE", "RE");
        //    manage = toolbar.MenuItems.Add("Admin", "Edit");
        //    manage = toolbar.MenuItems.Add("Main", "Default");
          
        
        //    manage = toolbar.MenuItems.Add("Search", "Search");
        
           
        //    return true;
        //}

    }
}
